<?php

namespace Admin\Models\statsexplain;

use Phalcon\Db\Column;
use Phalcon\Di;
class TreeHomeworkList extends ConnectOldCenter
{



    /**
     * Initialize method for model.
     */
    public function initialize()
    {
        parent::initialize();
        $this->setConnectionService(parent::Service);
    }

    /**
     * Returns table name mapped in the model.
     *
     * @return string
     */
    public function getSource()
    {
        return 'tree_homework_list';
    }

    /**
     * Allows to query a set of records that match the specified conditions
     *
     * @param mixed $parameters
     * @return Channel[]
     */
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }

    /**
     * Allows to query the first record that match the specified conditions
     *
     * @param mixed $parameters
     * @return channel
     */
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }

    /**
     * #方法说明：根据题库Id获取题库名称
     * @param $sysTrIds
     * @return array
    # Created by zsc
     */

    public static function getTrNameById($sysTrIds)
    {
        $data = [];
        if(!$sysTrIds) return $data;
        $parameters = self::find([
            'columns'    => 'tr_id,tr_name',
            'conditions' => 'tr_id IN ({idArr:array})',
            'bind'       => ['idArr' => $sysTrIds]
        ]);
        $list = self::find($parameters)->toArray();
        if(!$list) return $data;
        return array_column($list, 'tr_name', 'tr_id');
    }
}
